# 实例文件：cnt_owner.sh
# 使用bash统计文件所有者
# 将"ls -l"的输出通过管道传入该脚本


# must bash 4.0+
declare -A AACOUNT
while read -a LSL
do
    if(( ${#LSL[*]} > 7 ))
    then
        NDX=${LSL[3]}
        (( AACOUNT[$NDX] +=1 ))
    fi
done

for VALS in "${!AACOUNT[@]}"
do
    echo $VALS "owns" ${AACOUNT[$VALS]} "files"
done
